import java.util.HashMap;
import java.util.Map;
import java.util.Set;


public class Test1 {
    public static void main(String[] args) {
    }
    public static void main2(String[] args) {
        String s1="asd";
        String s2="asd";
        String s3=new String("asd");
        String s4=s3;
        System.out.println(s1==s2);
        System.out.println(s3==s4);
    }
    public static Map<String, Integer> countWord(String[] words) {
        Map<String, Integer> map = new HashMap<>();
        for (String s : words) {
            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                map.put(s, val + 1);
            }
        }
        return map;
    }

    public static void main1(String[] args) {
        String[] words = {"hello", "abc", "hello", "def", "this", "this", "this"};
//        Map<String, Integer> map = countWord(words);
//        Set<Map.Entry<String, Integer>> entrySet = map.entrySet();
//        for (Map.Entry<String, Integer> entry : entrySet) {
//            System.out.println("key: " + entry.getKey() + " val: " + entry.getValue());
//        }
        System.out.println(countWord(words));
    }
}
